﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:flowdoc="clr-namespace:NicoView.View.FlowDocuments"
             xmlns:local="clr-namespace:NicoView"
             
             xmlns:vm="clr-namespace:NicoView.ViewModel;assembly=NicoView.ViewModel"
             xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             
             xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="CommentListViewControl" x:Class="NicoView.View.NicoViewCommentViewControl"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Foreground="{x:Null}" Loaded="CommentListViewControl_Loaded" >


    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="./Dictionary/NicoViewCommentDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <CollectionViewSource x:Key="CommentViewSource"
                                  Source="{Binding Comments}"
                                  
                                  Filter="CommentViewSource_Filter">

                <CollectionViewSource.SortDescriptions>
                    <componentModel:SortDescription PropertyName="SortTime" Direction="Ascending"/>
                    <componentModel:SortDescription PropertyName="SecondSortTime" Direction="Ascending"/>
                </CollectionViewSource.SortDescriptions>
            </CollectionViewSource>

        </ResourceDictionary>
    </UserControl.Resources>





    <ListBox  x:Name="CommentListBox"  VirtualizingPanel.VirtualizationMode="Recycling"    BorderBrush="{x:Null}" BorderThickness="0"   ScrollViewer.HorizontalScrollBarVisibility="Disabled" LayoutUpdated="CommentListBox_LayoutUpdated" SelectionChanged="CommentListBox_SelectionChanged"   >
        <ListBox.Template>
            <ControlTemplate TargetType="{x:Type ListBox}">
                <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="1" SnapsToDevicePixels="True">
                    <ScrollViewer   x:Name="CommentScrollViwer"  Focusable="False" Padding="{TemplateBinding Padding}"  Loaded="CommentScrollViwer_Loaded" ScrollChanged="CommentScrollViwer_ScrollChanged" >
                        <ScrollViewer.Template>
                            <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                <Grid x:Name="Grid" Background="{TemplateBinding Background}" MouseWheel="Grid_MouseWheel" >
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Rectangle x:Name="Corner" Grid.Column="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Grid.Row="1" />
                                    <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
                                    <ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}" Scroll="PART_VerticalScrollBar_Scroll">
                                        <ScrollBar.Template>
                                            <ControlTemplate TargetType="{x:Type ScrollBar}">
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition MaxHeight="18"/>
                                                        <RowDefinition Height="1E-05*"/>
                                                        <RowDefinition MaxHeight="18"/>
                                                    </Grid.RowDefinitions>
                                                    <Border CornerRadius="0" Grid.RowSpan="3">
                                                        <Border.Background>
                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                <GradientStop Color="#FFD4DAE0" Offset="0"/>
                                                                <GradientStop Color="#FFDFE4EB" Offset="1"/>
                                                            </LinearGradientBrush>
                                                        </Border.Background>
                                                    </Border>
                                                    <RepeatButton x:Name="repeatButton" Background="White" Content="M 0 4 L 8 4 L 4 0 Z" Command="ScrollBar.LineUpCommand" Height="17" Margin="1,1,1,0" Grid.Row="0" VerticalAlignment="Top" Click="repeatButton_Click">
                                                        <RepeatButton.Style>
                                                            <Style TargetType="{x:Type RepeatButton}">
                                                                <Setter Property="SnapsToDevicePixels" Value="True"/>
                                                                <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                                <Setter Property="Focusable" Value="False"/>
                                                                <Setter Property="Template">
                                                                    <Setter.Value>
                                                                        <ControlTemplate TargetType="{x:Type RepeatButton}">
                                                                            <Border x:Name="Border" BorderBrush="#FF8A9199" BorderThickness="1" Background="#FFD9DEE3" CornerRadius="1" Margin="0">
                                                                                <Border x:Name="border" BorderThickness="1" CornerRadius="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                                                                    <Border.BorderBrush>
                                                                                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                            <GradientStop Color="#FFF0F4F8" Offset="0"/>
                                                                                            <GradientStop Color="#FFD7DBE1" Offset="1"/>
                                                                                        </LinearGradientBrush>
                                                                                    </Border.BorderBrush>
                                                                                    <Border.Background>
                                                                                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                            <GradientStop Color="#FFEFF3F7" Offset="0"/>
                                                                                            <GradientStop Color="#FFDADEE4" Offset="1"/>
                                                                                        </LinearGradientBrush>
                                                                                    </Border.Background>
                                                                                    <Path x:Name="path" Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Center" Height="Auto" VerticalAlignment="Center" Width="Auto"/>
                                                                                </Border>
                                                                            </Border>
                                                                            <ControlTemplate.Triggers>
                                                                                <Trigger Property="Background" Value="White">
                                                                                    <Setter Property="Background" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border" Value="#00000000"/>
                                                                                    <Setter Property="Background" TargetName="border" Value="#00000000"/>
                                                                                </Trigger>
                                                                                <MultiTrigger>
                                                                                    <MultiTrigger.Conditions>
                                                                                        <Condition Property="IsMouseOver" Value="True"/>
                                                                                        <Condition Property="IsPressed" Value="False"/>
                                                                                    </MultiTrigger.Conditions>
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#FF969EA8"/>
                                                                                    <Setter Property="Background" TargetName="Border" Value="#FFE5E9EB"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFFCFDFE" Offset="0"/>
                                                                                                <GradientStop Color="#FFF1F3F5" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                    <Setter Property="Background" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFF7FAFC" Offset="0"/>
                                                                                                <GradientStop Color="#FFE4E8EC" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                </MultiTrigger>
                                                                                <Trigger Property="IsPressed" Value="True">
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#FF8A9199"/>
                                                                                    <Setter Property="Background" TargetName="Border" Value="#FFD5D9DE"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFEAEEF2" Offset="0"/>
                                                                                                <GradientStop Color="#FFCFD4D9" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                    <Setter Property="Background" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFE9ECF0" Offset="0"/>
                                                                                                <GradientStop Color="#FFD2D7DC" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                </Trigger>
                                                                                <Trigger Property="IsEnabled" Value="False">
                                                                                    <Setter Property="Opacity" TargetName="path" Value="0.5"/>
                                                                                    <Setter Property="Background" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border" Value="#00000000"/>
                                                                                    <Setter Property="Background" TargetName="border" Value="#00000000"/>
                                                                                </Trigger>
                                                                            </ControlTemplate.Triggers>
                                                                        </ControlTemplate>
                                                                    </Setter.Value>
                                                                </Setter>
                                                                <Setter Property="Foreground">
                                                                    <Setter.Value>
                                                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                                            <GradientStop Color="#FF747576" Offset="0"/>
                                                                            <GradientStop Color="#FF454647" Offset="1"/>
                                                                        </LinearGradientBrush>
                                                                    </Setter.Value>
                                                                </Setter>
                                                            </Style>
                                                        </RepeatButton.Style>
                                                    </RepeatButton>
                                                    <Track x:Name="PART_Track" IsDirectionReversed="True" Grid.Row="1" ViewportSize="{TemplateBinding ViewportSize}">
                                                        <Track.Resources>
                                                            <System:Double x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">36</System:Double>
                                                        </Track.Resources>
                                                        <Track.DecreaseRepeatButton>
                                                            <RepeatButton Command="ScrollBar.PageUpCommand" >
                                                                <RepeatButton.Style>
                                                                    <Style TargetType="{x:Type RepeatButton}">
                                                                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                                                                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                                        <Setter Property="IsTabStop" Value="False"/>
                                                                        <Setter Property="Focusable" Value="False"/>
                                                                        <Setter Property="Template">
                                                                            <Setter.Value>
                                                                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                                                                    <Border Background="Transparent"/>
                                                                                </ControlTemplate>
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                    </Style>
                                                                </RepeatButton.Style>
                                                            </RepeatButton>
                                                        </Track.DecreaseRepeatButton>
                                                        <Track.IncreaseRepeatButton>
                                                            <RepeatButton Command="ScrollBar.PageDownCommand">
                                                                <RepeatButton.Style>
                                                                    <Style TargetType="{x:Type RepeatButton}">
                                                                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                                                                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                                        <Setter Property="IsTabStop" Value="False"/>
                                                                        <Setter Property="Focusable" Value="False"/>
                                                                        <Setter Property="Template">
                                                                            <Setter.Value>
                                                                                <ControlTemplate TargetType="{x:Type RepeatButton}">
                                                                                    <Border Background="Transparent"/>
                                                                                </ControlTemplate>
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                    </Style>
                                                                </RepeatButton.Style>
                                                            </RepeatButton>
                                                        </Track.IncreaseRepeatButton>
                                                        <Track.Thumb>
                                                            <Thumb Margin="1,0" RenderTransformOrigin="0.5,0.5">
                                                                <Thumb.Style>
                                                                    <Style TargetType="{x:Type Thumb}">
                                                                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                                                                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                                        <Setter Property="IsTabStop" Value="False"/>
                                                                        <Setter Property="Focusable" Value="False"/>
                                                                        <Setter Property="Template">
                                                                            <Setter.Value>
                                                                                <ControlTemplate TargetType="{x:Type Thumb}">
                                                                                    <Border x:Name="border" BorderBrush="#FF8A9199" BorderThickness="1" Background="#FFD9DEE3" CornerRadius="1">
                                                                                        <Border x:Name="border1" BorderThickness="1" ClipToBounds="True" CornerRadius="1" Padding="2" Width="Auto">
                                                                                            <Border.BorderBrush>
                                                                                                <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                    <GradientStop Color="#FFF0F4F8" Offset="0"/>
                                                                                                    <GradientStop Color="#FFD7DBE1" Offset="1"/>
                                                                                                </LinearGradientBrush>
                                                                                            </Border.BorderBrush>
                                                                                            <Border.Background>
                                                                                                <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                    <GradientStop Color="#FFEFF3F7" Offset="0"/>
                                                                                                    <GradientStop Color="#FFDADEE4" Offset="1"/>
                                                                                                </LinearGradientBrush>
                                                                                            </Border.Background>
                                                                                            <StackPanel HorizontalAlignment="Center" Height="Auto" Orientation="Vertical" Visibility="Visible" VerticalAlignment="Center" Width="8">
                                                                                                <Rectangle Height="1" Margin="0" Stroke="#66000000" Width="Auto"/>
                                                                                                <Rectangle Height="1" Margin="2,0,0,0" Stroke="#66F8F8F8" Width="Auto"/>
                                                                                                <Rectangle Height="1" Margin="0" Stroke="#66000000" Width="Auto"/>
                                                                                                <Rectangle Height="1" Margin="2,0,0,0" Stroke="#66F8F8F8" Width="Auto"/>
                                                                                                <Rectangle Height="1" Margin="0" Stroke="#66000000" Width="Auto"/>
                                                                                                <Rectangle Height="1" Margin="2,0,0,0" Stroke="#66F8F8F8" Width="Auto"/>
                                                                                                <Rectangle Height="1" Margin="0" Stroke="#66000000" Width="Auto"/>
                                                                                                <Rectangle Height="1" Margin="2,0,0,0" Stroke="#66F8F8F8" Width="Auto"/>
                                                                                            </StackPanel>
                                                                                        </Border>
                                                                                    </Border>
                                                                                    <ControlTemplate.Triggers>
                                                                                        <Trigger Property="IsDragging" Value="True">
                                                                                            <Setter Property="Background" TargetName="border" Value="#FFD5D9DE"/>
                                                                                            <Setter Property="BorderBrush" TargetName="border" Value="#FF8A9199"/>
                                                                                            <Setter Property="BorderBrush" TargetName="border1">
                                                                                                <Setter.Value>
                                                                                                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                        <GradientStop Color="#FFEAEEF2" Offset="0"/>
                                                                                                        <GradientStop Color="#FFCFD4D9" Offset="1"/>
                                                                                                    </LinearGradientBrush>
                                                                                                </Setter.Value>
                                                                                            </Setter>
                                                                                            <Setter Property="Background" TargetName="border1">
                                                                                                <Setter.Value>
                                                                                                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                        <GradientStop Color="#FFE9ECF0" Offset="0"/>
                                                                                                        <GradientStop Color="#FFD2D7DC" Offset="1"/>
                                                                                                    </LinearGradientBrush>
                                                                                                </Setter.Value>
                                                                                            </Setter>
                                                                                        </Trigger>
                                                                                        <Trigger Property="IsMouseOver" Value="True">
                                                                                            <Setter Property="Background" TargetName="border" Value="#FFE5E9EB"/>
                                                                                            <Setter Property="BorderBrush" TargetName="border" Value="#FF969EA8"/>
                                                                                            <Setter Property="BorderBrush" TargetName="border1">
                                                                                                <Setter.Value>
                                                                                                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                        <GradientStop Color="#FFFCFDFE" Offset="0"/>
                                                                                                        <GradientStop Color="#FFF1F3F5" Offset="1"/>
                                                                                                    </LinearGradientBrush>
                                                                                                </Setter.Value>
                                                                                            </Setter>
                                                                                            <Setter Property="Background" TargetName="border1">
                                                                                                <Setter.Value>
                                                                                                    <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                        <GradientStop Color="#FFF7FAFC" Offset="0"/>
                                                                                                        <GradientStop Color="#FFE4E8EC" Offset="1"/>
                                                                                                    </LinearGradientBrush>
                                                                                                </Setter.Value>
                                                                                            </Setter>
                                                                                        </Trigger>
                                                                                    </ControlTemplate.Triggers>
                                                                                </ControlTemplate>
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                    </Style>
                                                                </Thumb.Style>
                                                            </Thumb>
                                                        </Track.Thumb>
                                                    </Track>
                                                    <RepeatButton x:Name="repeatButton1" Background="White" Content="M 0 0 L 4 4 L 8 0 Z" Command="ScrollBar.LineDownCommand" Height="17" Margin="1,0,1,1" Grid.Row="3">
                                                        <RepeatButton.Style>
                                                            <Style TargetType="{x:Type RepeatButton}">
                                                                <Setter Property="SnapsToDevicePixels" Value="True"/>
                                                                <Setter Property="OverridesDefaultStyle" Value="True"/>
                                                                <Setter Property="Focusable" Value="False"/>
                                                                <Setter Property="Template">
                                                                    <Setter.Value>
                                                                        <ControlTemplate TargetType="{x:Type RepeatButton}">
                                                                            <Border x:Name="Border" BorderBrush="#FF8A9199" BorderThickness="1" Background="#FFD9DEE3" CornerRadius="1" Margin="0">
                                                                                <Border x:Name="border" BorderThickness="1" CornerRadius="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                                                                    <Border.BorderBrush>
                                                                                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                            <GradientStop Color="#FFF0F4F8" Offset="0"/>
                                                                                            <GradientStop Color="#FFD7DBE1" Offset="1"/>
                                                                                        </LinearGradientBrush>
                                                                                    </Border.BorderBrush>
                                                                                    <Border.Background>
                                                                                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                            <GradientStop Color="#FFEFF3F7" Offset="0"/>
                                                                                            <GradientStop Color="#FFDADEE4" Offset="1"/>
                                                                                        </LinearGradientBrush>
                                                                                    </Border.Background>
                                                                                    <Path x:Name="path" Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Center" Height="Auto" VerticalAlignment="Center" Width="Auto"/>
                                                                                </Border>
                                                                            </Border>
                                                                            <ControlTemplate.Triggers>
                                                                                <Trigger Property="Background" Value="White">
                                                                                    <Setter Property="Background" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border" Value="#00000000"/>
                                                                                    <Setter Property="Background" TargetName="border" Value="#00000000"/>
                                                                                </Trigger>
                                                                                <MultiTrigger>
                                                                                    <MultiTrigger.Conditions>
                                                                                        <Condition Property="IsMouseOver" Value="True"/>
                                                                                        <Condition Property="IsPressed" Value="False"/>
                                                                                    </MultiTrigger.Conditions>
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#FF969EA8"/>
                                                                                    <Setter Property="Background" TargetName="Border" Value="#FFE5E9EB"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFFCFDFE" Offset="0"/>
                                                                                                <GradientStop Color="#FFF1F3F5" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                    <Setter Property="Background" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFF7FAFC" Offset="0"/>
                                                                                                <GradientStop Color="#FFE4E8EC" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                </MultiTrigger>
                                                                                <Trigger Property="IsPressed" Value="True">
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#FF8A9199"/>
                                                                                    <Setter Property="Background" TargetName="Border" Value="#FFD5D9DE"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFEAEEF2" Offset="0"/>
                                                                                                <GradientStop Color="#FFCFD4D9" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                    <Setter Property="Background" TargetName="border">
                                                                                        <Setter.Value>
                                                                                            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                                                                                <GradientStop Color="#FFE9ECF0" Offset="0"/>
                                                                                                <GradientStop Color="#FFD2D7DC" Offset="1"/>
                                                                                            </LinearGradientBrush>
                                                                                        </Setter.Value>
                                                                                    </Setter>
                                                                                </Trigger>
                                                                                <Trigger Property="IsEnabled" Value="False">
                                                                                    <Setter Property="Opacity" TargetName="path" Value="0.5"/>
                                                                                    <Setter Property="Background" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="Border" Value="#00000000"/>
                                                                                    <Setter Property="BorderBrush" TargetName="border" Value="#00000000"/>
                                                                                    <Setter Property="Background" TargetName="border" Value="#00000000"/>
                                                                                </Trigger>
                                                                            </ControlTemplate.Triggers>
                                                                        </ControlTemplate>
                                                                    </Setter.Value>
                                                                </Setter>
                                                                <Setter Property="Foreground">
                                                                    <Setter.Value>
                                                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                                            <GradientStop Color="#FF747576" Offset="0"/>
                                                                            <GradientStop Color="#FF454647" Offset="1"/>
                                                                        </LinearGradientBrush>
                                                                    </Setter.Value>
                                                                </Setter>
                                                            </Style>
                                                        </RepeatButton.Style>
                                                    </RepeatButton>
                                                </Grid>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Setter Property="Background" TargetName="repeatButton" Value="{x:Null}"/>
                                                        <Setter Property="Background" TargetName="repeatButton1" Value="{x:Null}"/>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </ScrollBar.Template>
                                    </ScrollBar>
                                    <ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
                                </Grid>
                            </ControlTemplate>
                        </ScrollViewer.Template>
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </ScrollViewer>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Background" TargetName="Bd" Value="White"/>
                        <Setter Property="BorderBrush" TargetName="Bd" Value="#FFD9D9D9"/>
                    </Trigger>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="IsGrouping" Value="True"/>
                        </MultiTrigger.Conditions>
                        <Setter Property="ScrollViewer.CanContentScroll" Value="False"/>
                    </MultiTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </ListBox.Template>


        <ListBox.Resources>
            <Style TargetType="ListBoxItem">
                <Style.Triggers>
                    <Trigger Property="IsKeyboardFocusWithin" Value="true">
                        <Setter Property="IsSelected" Value="true" />
                    </Trigger>

                </Style.Triggers>

            </Style>

        </ListBox.Resources>
        <ListBox.ItemsSource>
            <Binding Mode="OneWay" Source="{StaticResource CommentViewSource}"/>
        </ListBox.ItemsSource>
        <ListBox.ItemTemplate>

            <DataTemplate>
                <Border x:Name="ItemBorder"  BorderThickness="0,0,0,1" BorderBrush="LightGray"    >
                    <Border.Background>
                        <SolidColorBrush Color="{Binding BackGroundColor}"/>
                    </Border.Background>

                    <Grid Margin="3,0"   >
                        <Grid.InputBindings>
                            <MouseBinding Gesture="LeftDoubleClick" Command="{Binding BackGroundColorChangeCommand}" />
                        </Grid.InputBindings>


                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Image Source="{Binding Converter={StaticResource UserImagePathConverter}}" Width="42" Height="42"  Grid.Column="0" Style="{Binding Mode=OneWay, Source={StaticResource CommentUserImage}}"   />


                        <RichTextBox  x:Name="BodyText" IsReadOnly="True" IsDocumentEnabled="True"   Grid.Column="1"  BorderBrush="{x:Null}"  BorderThickness="0" Background="{x:Null}" IsManipulationEnabled="True"  >
                            <RichTextBox.InputBindings>
                                <MouseBinding Gesture="LeftDoubleClick" Command="{Binding BackGroundColorChangeCommand}" />
                            </RichTextBox.InputBindings>
                            <FlowDocument >

                                <flowdoc:BindableNicoCommentParagraph x:Name="CommentContent"  BoundComment="{Binding}" MouseDown="CommentContent_MouseDown"/>

                            </FlowDocument>
                        </RichTextBox>

                    </Grid>
                </Border>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

</UserControl>
